import request from '@/assets/js/request';
import util from '@/assets/js/public';

export function login(params){      
    let url=util.toUrl(`${process.env.VUE_APP_DEVBASEURL}/action/oauth2/refreshToken`,params || {});  
    return request({
        url:url,
        // data:params,
        // contentType:'application/json;charset=UTF-8',
        catch:true
    })
}

export function loginFast(){    
    return request({
        url:`${process.env.VUE_APP_URL}/api/restLogin`,
        contentType:'application/json;charset=UTF-8'
    })
}
export function sendMes(phone){
    return request({
        url:`${process.env.VUE_APP_URL}/action/logic/sendMsg/anonymous?phone=`+phone,
        message:false,
        catch:true
    });
}
export function getPhone(token){
    return request({
        url:`${process.env.VUE_APP_URL}/action/logic/getPhone/anonymous?token=`+token,
        catch:true
    });
}
export function oauthToken(params){
    let url=util.toUrl(`${process.env.VUE_APP_URL}/action/oauth2/refreshToken`,params || {});
    return request({
        url:url
    });
}
export function getInfo(){
    return request({
        url:`${process.env.VUE_APP_URL}/getCurrentUser/api`,///getCurrentUser
    })
}
export function captcha(){
    return request({
        url:'/captcha',
        method:'get',
        responseType: 'blob',
        contentType:'application/json;charset=UTF-8'
    })
}
export function logout(){
    return request({
        url:`${process.env.VUE_APP_URL}/restuumslogout`
    })
}
export function getToken(){
    return request({
        url:`${process.env.VUE_APP_URL}/action/logic/getToken/anonymous`
    })
}
export function appPost(params){
    return request({
        url:`${process.env.VUE_APP_URL}/app/mobilev21/token/validation`,
        contentType:'application/json;charset=UTF-8',
        data:params
    })
}
export function updateCheckedZone(zone){
    return request({
        url:`${process.env.VUE_APP_URL}/common/user/changeZone`,
        data:{
            zoneId:zone.id,
            appcode:process.env.VUE_APP_APPLOGINCODE
        },
        noCurrent:true
    })
}
export function getMenus(currentUserCode){
    return request({
        url:`${process.env.VUE_APP_URL}/exuums/sys/userinfo/api/findPermissionByAppUser?source=` + process.env.VUE_APP_SOURCE + '&currentUserCode=' + util.encrypt(currentUserCode)       
    })
}
export function findByKey(params){
    return request({
        url:`${process.env.VUE_APP_URL}/uums/sys/userinfo/findByKey`,
        data:params
    })
}

